package com.zy.design.demo.structural;

/**
 * 桥接模式
 * 特点：将抽象部分与实现部分分离，使它们可以独立变化。
 */
interface Device {
    void turnOn();
}

class TV implements Device {
    public void turnOn() { System.out.println("电视打开了"); }
}

abstract class RemoteControl {
    protected Device device;

    public RemoteControl(Device device) { this.device = device; }
    abstract void powerOn();
}

class BasicRemote extends RemoteControl {
    public BasicRemote(Device device) { super(device); }

    @Override
    public void powerOn() {
        System.out.print("使用基本遥控器：");
        device.turnOn();
    }
}

class Main1 {
    public static void main(String[] args) {
        Device tv = new TV();
        RemoteControl remote = new BasicRemote(tv);
        remote.powerOn();
    }
}
